package com.cskaoyan.dbutils.queryrunner;

import com.cskaoyan.connectionpool.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;

public class QueryRunnerDemo {

    public static void main(String[] args) throws SQLException {

        QueryRunner queryRunner = new QueryRunner();

        // QueryRunner有两个构造方法，
        // 1. 无参构造
        // 2. 传入一个数据库连接池来构造

        Connection connection = DruidUtils.getConnection();

        int affectedRows = queryRunner.update(connection, "update account set money = ? where name = ?", 10000, "珠珠");


        System.out.println("affectedRows:" + affectedRows);

        connection.close();


    }
}
